//
//  ChatFunctionView.m
//  学生汇
//
//  Created by yull on 14/12/7.
//  Copyright (c) 2014年 于博. All rights reserved.
//

#import "ChatFunctionView.h"
#import "UIColor+MethodExt.h"
@implementation ChatFunctionView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor colorWithHexString:@"F3F2EE"];
        
        UIImageView * imageViewLine1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 107, SCREEN_WIDTH, 1)];
        imageViewLine1.image = [UIImage imageNamed:@"横线@2x.png"];
        [self addSubview:imageViewLine1];
        
        UIImageView * imageViewLine2 = [[UIImageView alloc] initWithFrame:CGRectMake(79, 0, 1, 215)];
        imageViewLine2.image = [UIImage imageNamed:@"竖线@2x.png"];
        [self addSubview:imageViewLine2];
        
        UIImageView * imageViewLine3 = [[UIImageView alloc] initWithFrame:CGRectMake(79*2, 0, 1, 215)];
        imageViewLine3.image = [UIImage imageNamed:@"竖线@2x.png"];
        [self addSubview:imageViewLine3];
        
        UIImageView * imageViewLine4 = [[UIImageView alloc] initWithFrame:CGRectMake(79*3, 0, 1, 215)];
        imageViewLine4.image = [UIImage imageNamed:@"竖线@2x.png"];
        [self addSubview:imageViewLine4];
        
        //图片
        UIButton * buttonF1 = [UIButton buttonWithType:UIButtonTypeCustom];
        buttonF1.frame = CGRectMake(0, 0, 79, 107);
        [buttonF1 setBackgroundImage:[UIImage imageNamed:@"chat_pic_back"] forState:UIControlStateHighlighted];
        [buttonF1 addTarget:self action:@selector(f2Click) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:buttonF1];
        
        UIImageView * imageViewF1 = [[UIImageView alloc] initWithFrame:CGRectMake((79 - 32)/2, 26, 32, 33)];
        imageViewF1.image = [UIImage imageNamed:@"chat_pic_pick"];
        [buttonF1 addSubview:imageViewF1];
        
        UILabel * labelF1 = [[UILabel alloc] initWithFrame:CGRectMake(0, imageViewF1.frame.origin.y + imageViewF1.frame.size.height + 13, 79, 14)];
        labelF1.backgroundColor = [UIColor clearColor];
        labelF1.font = [UIFont systemFontOfSize:14];
        labelF1.textColor = [UIColor colorWithHexString:@"6E6E6E"];
        labelF1.textAlignment = NSTextAlignmentCenter;
        labelF1.text = @"图片";
        [buttonF1 addSubview:labelF1];
        
        //拍摄
        UIButton * buttonF2 = [UIButton buttonWithType:UIButtonTypeCustom];
        buttonF2.frame = CGRectMake(buttonF1.frame.origin.x + buttonF1.frame.size.width, 0, 79, 107);
        [buttonF2 setBackgroundImage:[UIImage imageNamed:@"chat_pic_back"] forState:UIControlStateHighlighted];
        [buttonF2 addTarget:self action:@selector(f3Click) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:buttonF2];
        
        UIImageView * imageViewF2 = [[UIImageView alloc] initWithFrame:CGRectMake((79 - 32)/2, 26, 32, 33)];
        imageViewF2.image = [UIImage imageNamed:@"chat_pic_take"];
        [buttonF2 addSubview:imageViewF2];
        
        UILabel * labelF2 = [[UILabel alloc] initWithFrame:CGRectMake(0, imageViewF1.frame.origin.y + imageViewF1.frame.size.height + 13, 79, 14)];
        labelF2.backgroundColor = [UIColor clearColor];
        labelF2.font = [UIFont systemFontOfSize:14];
        labelF2.textColor = [UIColor colorWithHexString:@"6E6E6E"];
        labelF2.textAlignment = NSTextAlignmentCenter;
        labelF2.text = @"拍摄";
        [buttonF2 addSubview:labelF2];
    }
    return self;
}

- (void)f2Click{
    if ([self.delegate respondsToSelector:@selector(selectImageFromAlbum)]) {
        [self.delegate selectImageFromAlbum];
    }
}

- (void)f3Click{
    if ([self.delegate respondsToSelector:@selector(takePhoto)]) {
        [self.delegate takePhoto];
    }
}
@end
